package mapper;

import Message.vo.CategoryPageVO;
import Message.vo.CategoryVO;
import anno.AutoFill;
import enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;


public interface CategoryMapper {

    List<CategoryVO> SelectPage(CategoryPageVO category);


    int countPage(CategoryPageVO category);

    @AutoFill(OperationType.UPDATE)
    @Update("update category set name=#{name},sort=#{sort},update_time=#{update_time},type=#{type} where id =#{id}")
    void UpdateCategory(CategoryVO category);

    @AutoFill(OperationType.UPDATE)
    @Update("update category set status=#{status} where id=#{id}")
    void UpdateCategoryStatus(Integer status, long id);


    @Delete("delete from category where id=#{id}")
    void DeleteCategory(Long id);

    @AutoFill(OperationType.INSERT)
    @Insert("insert into category(name,sort,type,status,create_time, update_time, create_user, update_user) values(#{name},#{sort},#{type},#{status},#{create_time}, #{update_time}, #{create_user}, #{update_user})")
    void AddCategory(CategoryVO category);

    @Select("select * from category where type=#{type}   order by sort asc,create_time desc")
    List<CategoryVO> ListCategory(Integer type);


    List<CategoryVO> getCategoryList(Integer type);
}
